﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Net.Mime.MediaTypeNames;

namespace MicroLED_Detecter
{
    public class ImageTools
    {
        bool line45 = false;
        bool line40 = false;
        bool line35 = false;
        bool line30 = false;
        bool line25 = false;
        bool line20 = false;
        bool line15 = false;
        bool line10 = false;
        bool line07 = false;
        bool line45mark = false;
        bool line40mark = false;
        bool line35mark = false;
        bool line30mark = false;
        bool line25mark = false;
        bool line20mark = false;
        bool line15mark = false;
        bool line10mark = false;
        bool line07mark = false;

        public bool Opticalpower_Changed(string Opticalpower)
        {
            if (Opticalpower == null)
                return false;
            else
                return true;
        }
        public void Confirm_Opticalpower(string IsShoworCloPositionline, string IsShoworCloTickmaks, string Opticalpower)
        {
            if (IsShoworCloPositionline == "隐藏")
            {
                if (Opticalpower == "光学倍率：1X 0.7X 20X")
                {
                    line07 = true;
                    line10 = false; line15 = false; line20 = false; line25 = false; line30 = false; line35 = false; line40 = false; line45 = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 1.0X 20X")
                {
                    line10 = true;
                    line07 = false; line15 = false; line20 = false; line25 = false; line30 = false; line35 = false; line40 = false; line45 = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 1.5X 20X")
                {
                    line15 = true;
                    line10 = false; line07 = false; line20 = false; line25 = false; line30 = false; line35 = false; line40 = false; line45 = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 2.0X 20X")
                {
                    line20 = true;
                    line10 = false; line15 = false; line07 = false; line25 = false; line30 = false; line35 = false; line40 = false; line45 = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 2.5X 20X")
                {
                    line25 = true;
                    line10 = false; line15 = false; line20 = false; line07 = false; line30 = false; line35 = false; line40 = false; line45 = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 3.0X 20X")
                {
                    line30 = true;
                    line10 = false; line15 = false; line20 = false; line25 = false; line07 = false; line35 = false; line40 = false; line45 = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 3.5X 20X")
                {
                    line35 = true;
                    line10 = false; line15 = false; line20 = false; line25 = false; line30 = false; line07 = false; line40 = false; line45 = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 4.0X 20X")
                {
                    line40 = true;
                    line10 = false; line15 = false; line20 = false; line25 = false; line30 = false; line35 = false; line07 = false; line45 = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 4.5X 20X")
                {
                    line45 = true;
                    line10 = false; line15 = false; line20 = false; line25 = false; line30 = false; line35 = false; line40 = false; line07 = false;//互锁
                }
                else { }
            }
            else//btn_ShoworCloPositionline.Text == "显示"
            {
                line07 = false; line10 = false; line15 = false; line20 = false; line25 = false; line30 = false; line35 = false; line40 = false; line45 = false;
            }
            if (IsShoworCloTickmaks == "隐藏")
            {
                if (Opticalpower == "光学倍率：1X 0.7X 20X")
                {
                    line07mark = true;
                    line10mark = false; line15mark = false; line20mark = false; line25mark = false; line30mark = false; line35mark = false; line40mark = false; line45mark = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 1.0X 20X")
                {
                    line10mark = true;
                    line07mark = false; line15mark = false; line20mark = false; line25mark = false; line30mark = false; line35mark = false; line40mark = false; line45mark = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 1.5X 20X")
                {
                    line15mark = true;
                    line10mark = false; line07mark = false; line20mark = false; line25mark = false; line30mark = false; line35mark = false; line40mark = false; line45mark = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 2.0X 20X")
                {
                    line20mark = true;
                    line10mark = false; line15mark = false; line07mark = false; line25mark = false; line30mark = false; line35mark = false; line40mark = false; line45mark = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 2.5X 20X")
                {
                    line25mark = true;
                    line10mark = false; line15mark = false; line20mark = false; line07mark = false; line30mark = false; line35mark = false; line40mark = false; line45mark = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 3.0X 20X")
                {
                    line30mark = true;
                    line10mark = false; line15mark = false; line20mark = false; line25mark = false; line07mark = false; line35mark = false; line40mark = false; line45mark = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 3.5X 20X")
                {
                    line35mark = true;
                    line10mark = false; line15mark = false; line20mark = false; line25mark = false; line30mark = false; line07mark = false; line40mark = false; line45mark = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 4.0X 20X")
                {
                    line40mark = true;
                    line10mark = false; line15mark = false; line20mark = false; line25mark = false; line30mark = false; line35mark = false; line07mark = false; line45mark = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 4.5X 20X")
                {
                    line45mark = true;
                    line10mark = false; line15mark = false; line20mark = false; line25mark = false; line30mark = false; line35mark = false; line40mark = false; line07mark = false;//互锁
                }
                else { }
            }
            else//btn_ShoworCloTickmaks.Text == "显示"
            {
                line07mark = false; line10mark = false; line15mark = false; line20mark = false; line25mark = false; line30mark = false; line35mark = false; line40mark = false; line45mark = false;
            }
        }
        public int ShoworCloPositionline(string Opticalpower)
        {
            if (line07 == false && line10 == false && line15 == false && line20 == false && line25 == false && line30 == false && line35 == false && line40 == false && line45 == false)
            {
                if (Opticalpower == "光学倍率：1X 0.7X 20X")
                {
                    line07 = true;
                    line10 = false; line15 = false; line20 = false; line25 = false; line30 = false; line35 = false; line40 = false; line45 = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 1.0X 20X")
                {
                    line10 = true;
                    line07 = false; line15 = false; line20 = false; line25 = false; line30 = false; line35 = false; line40 = false; line45 = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 1.5X 20X")
                {
                    line15 = true;
                    line10 = false; line07 = false; line20 = false; line25 = false; line30 = false; line35 = false; line40 = false; line45 = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 2.0X 20X")
                {
                    line20 = true;
                    line10 = false; line15 = false; line07 = false; line25 = false; line30 = false; line35 = false; line40 = false; line45 = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 2.5X 20X")
                {
                    line25 = true;
                    line10 = false; line15 = false; line20 = false; line07 = false; line30 = false; line35 = false; line40 = false; line45 = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 3.0X 20X")
                {
                    line30 = true;
                    line10 = false; line15 = false; line20 = false; line25 = false; line07 = false; line35 = false; line40 = false; line45 = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 3.5X 20X")
                {
                    line35 = true;
                    line10 = false; line15 = false; line20 = false; line25 = false; line30 = false; line07 = false; line40 = false; line45 = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 4.0X 20X")
                {
                    line40 = true;
                    line10 = false; line15 = false; line20 = false; line25 = false; line30 = false; line35 = false; line07 = false; line45 = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 4.5X 20X")
                {
                    line45 = true;
                    line10 = false; line15 = false; line20 = false; line25 = false; line30 = false; line35 = false; line40 = false; line07 = false;//互锁
                }
                else { }
                return 0;
            }
            else
            {
                line07 = false; line10 = false; line15 = false; line20 = false; line25 = false; line30 = false; line35 = false; line40 = false; line45 = false;
                return 1;
            }
        }
        public int ShoworCloTickmaks(string Opticalpower)
        {
            if (line07mark == false && line10mark == false && line15mark == false && line20mark == false && line25mark == false && line30mark == false && line35mark == false && line40mark == false && line45mark == false)
            {
                if (Opticalpower == "光学倍率：1X 0.7X 20X")
                {
                    line07mark = true;
                    line10mark = false; line15mark = false; line20mark = false; line25mark = false; line30mark = false; line35mark = false; line40mark = false; line45mark = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 1.0X 20X")
                {
                    line10mark = true;
                    line07mark = false; line15mark = false; line20mark = false; line25mark = false; line30mark = false; line35mark = false; line40mark = false; line45mark = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 1.5X 20X")
                {
                    line15mark = true;
                    line10mark = false; line07mark = false; line20mark = false; line25mark = false; line30mark = false; line35mark = false; line40mark = false; line45mark = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 2.0X 20X")
                {
                    line20mark = true;
                    line10mark = false; line15mark = false; line07mark = false; line25mark = false; line30mark = false; line35mark = false; line40mark = false; line45mark = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 2.5X 20X")
                {
                    line25mark = true;
                    line10mark = false; line15mark = false; line20mark = false; line07mark = false; line30mark = false; line35mark = false; line40mark = false; line45mark = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 3.0X 20X")
                {
                    line30mark = true;
                    line10mark = false; line15mark = false; line20mark = false; line25mark = false; line07mark = false; line35mark = false; line40mark = false; line45mark = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 3.5X 20X")
                {
                    line35mark = true;
                    line10mark = false; line15mark = false; line20mark = false; line25mark = false; line30mark = false; line07mark = false; line40mark = false; line45mark = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 4.0X 20X")
                {
                    line40mark = true;
                    line10mark = false; line15mark = false; line20mark = false; line25mark = false; line30mark = false; line35mark = false; line07mark = false; line45mark = false;//互锁
                }
                else if (Opticalpower == "光学倍率：1X 4.5X 20X")
                {
                    line45mark = true;
                    line10mark = false; line15mark = false; line20mark = false; line25mark = false; line30mark = false; line35mark = false; line40mark = false; line07mark = false;//互锁
                }
                else { }
                return 0;
            }
            else
            {
                line07mark = false; line10mark = false; line15mark = false; line20mark = false; line25mark = false; line30mark = false; line35mark = false; line40mark = false; line45mark = false;
                return 1;
            }
        }

        public void Paint(PaintEventArgs e)
        {
            Pen pen1 = new Pen(Color.Red, 1);//创建一个宽度为1的红色画笔
            Pen pen2 = new Pen(Color.White, 5);//创建一个宽度为5的白色画笔
            Pen pen3 = new Pen(Color.Red, 2);//创建一个宽度为2的红色画笔
            Pen pen4 = new Pen(Color.Red, 3);//创建一个宽度为3的红色画笔
            /*Pen pen4 = new Pen(Color.Green, 1);//创建一个宽度为1的绿色画笔
            for (int i = 0; i < 10; i++)
            {
                Point startPointx = new Point(0 + 100 * i, 0);
                Point endPointx = new Point(0 + 100 * i, 1000);
                e.Graphics.DrawLine(pen4, startPointx, endPointx);
            }
            for (int i = 0; i < 10; i++)
            {
                Point startPointy = new Point(0, 0 + 100 * i);
                Point endPointy = new Point(1000, 0 + 100 * i);
                e.Graphics.DrawLine(pen4, startPointy, endPointy);
            }*/
            if (line45 == true)
            {
                //1X 4.5X 20X 光学倍率下的定位标识线
                Point startPoint451 = new Point(40, 321);
                Point endPoint451 = new Point(865, 321);
                e.Graphics.DrawLine(pen4, startPoint451, endPoint451);

                Point startPoint452 = new Point(40, 60);
                Point endPoint452 = new Point(780, 60);
                e.Graphics.DrawLine(pen3, startPoint452, endPoint452);

                Point startPoint453 = new Point(40, 590);
                Point endPoint453 = new Point(865, 590);
                e.Graphics.DrawLine(pen3, startPoint453, endPoint453);

                Point startPoint454 = new Point(40, 225);
                Point endPoint454 = new Point(865, 225);
                e.Graphics.DrawLine(pen3, startPoint454, endPoint454);

                Point startPoint455 = new Point(40, 425);
                Point endPoint455 = new Point(865, 425);
                e.Graphics.DrawLine(pen3, startPoint455, endPoint455);

                Point startPoint456 = new Point(460, 150);
                Point endPoint456 = new Point(460, 500);
                e.Graphics.DrawLine(pen4, startPoint456, endPoint456);

                Point startPoint457 = new Point(400, 250);
                Point endPoint457 = new Point(400, 400);
                e.Graphics.DrawLine(pen1, startPoint457, endPoint457);

                Point startPoint458 = new Point(520, 250);
                Point endPoint458 = new Point(520, 400);
                e.Graphics.DrawLine(pen1, startPoint458, endPoint458);

                Point startPoint459 = new Point(290, 250);
                Point endPoint459 = new Point(290, 400);
                e.Graphics.DrawLine(pen1, startPoint459, endPoint459);

                Point startPoint4510 = new Point(170, 250);
                Point endPoint4510 = new Point(170, 400);
                e.Graphics.DrawLine(pen1, startPoint4510, endPoint4510);

                Point startPoint4511 = new Point(630, 250);
                Point endPoint4511 = new Point(630, 400);
                e.Graphics.DrawLine(pen1, startPoint4511, endPoint4511);

                Point startPoint4512 = new Point(750, 250);
                Point endPoint4512 = new Point(750, 400);
                e.Graphics.DrawLine(pen1, startPoint4512, endPoint4512);
            }
            else {/*无操作，不划线*/}

            if (line45mark == true)
            {
                //1X 4.5X 20X 光学倍率下的刻度参考线
                Point startPoint4513 = new Point(780, 115);
                Point endPoint4513 = new Point(850, 115);
                e.Graphics.DrawLine(pen2, startPoint4513, endPoint4513);
                //在刻度参考线上绘制参考刻度
                string text451 = "10 μm";
                Font font451 = new Font("Arial", 20);
                Brush brush451 = Brushes.White;
                Point textPosition451 = new Point(770, 80);
                e.Graphics.DrawString(text451, font451, brush451, textPosition451);
                //倍率显示
                string text452 = "90X";
                Font font452 = new Font("Arial", 20);
                Brush brush452 = Brushes.White;
                Point textPosition452 = new Point(785, 40);
                e.Graphics.DrawString(text452, font452, brush452, textPosition452);
            }
            else {/*无操作，不划线*/}

            if (line40 == true)
            {
                Point startPoint401 = new Point(40, 321);
                Point endPoint401 = new Point(865, 321);
                e.Graphics.DrawLine(pen4, startPoint401, endPoint401);

                Point startPoint402 = new Point(40, 407);
                Point endPoint402 = new Point(865, 407);
                e.Graphics.DrawLine(pen3, startPoint402, endPoint402);

                Point startPoint403 = new Point(40, 235);
                Point endPoint403 = new Point(865, 235);
                e.Graphics.DrawLine(pen3, startPoint403, endPoint403);

                Point startPoint404 = new Point(40, 80);
                Point endPoint404 = new Point(750, 80);
                e.Graphics.DrawLine(pen3, startPoint404, endPoint404);

                Point startPoint405 = new Point(40, 562);
                Point endPoint405 = new Point(865, 562);
                e.Graphics.DrawLine(pen3, startPoint405, endPoint405);

                Point startPoint406 = new Point(460, 150);
                Point endPoint406 = new Point(460, 500);
                e.Graphics.DrawLine(pen4, startPoint406, endPoint406);

                Point startPoint407 = new Point(415, 250);
                Point endPoint407 = new Point(415, 400);
                e.Graphics.DrawLine(pen1, startPoint407, endPoint407);

                Point startPoint408 = new Point(505, 250);
                Point endPoint408 = new Point(505, 400);
                e.Graphics.DrawLine(pen1, startPoint408, endPoint408);

                Point startPoint409 = new Point(305, 250);
                Point endPoint409 = new Point(305, 400);
                e.Graphics.DrawLine(pen1, startPoint409, endPoint409);

                Point startPoint4010 = new Point(105, 250);
                Point endPoint4010 = new Point(105, 400);
                e.Graphics.DrawLine(pen1, startPoint4010, endPoint4010);

                Point startPoint4011 = new Point(215, 250);
                Point endPoint4011 = new Point(215, 400);
                e.Graphics.DrawLine(pen1, startPoint4011, endPoint4011);

                Point startPoint4012 = new Point(615, 250);
                Point endPoint4012 = new Point(615, 400);
                e.Graphics.DrawLine(pen1, startPoint4012, endPoint4012);

                Point startPoint4013 = new Point(705, 250);
                Point endPoint4013 = new Point(705, 400);
                e.Graphics.DrawLine(pen1, startPoint4013, endPoint4013);

                Point startPoint4014 = new Point(815, 250);
                Point endPoint4014 = new Point(815, 400);
                e.Graphics.DrawLine(pen3, startPoint4014, endPoint4014);
            }
            else {/*无操作，不划线*/}

            if (line40mark == true)
            {
                //1X 4.0X 20X 光学倍率下的刻度参考线
                Point startPoint4015 = new Point(760, 115);
                Point endPoint4015 = new Point(870, 115);
                e.Graphics.DrawLine(pen2, startPoint4015, endPoint4015);
                //在刻度参考线上绘制参考刻度
                string text401 = "20 μm";
                Font font401 = new Font("Arial", 20);
                Brush brush401 = Brushes.White;
                Point textPosition401 = new Point(770, 80);
                e.Graphics.DrawString(text401, font401, brush401, textPosition401);
                //倍率显示
                string text402 = "80X";
                Font font402 = new Font("Arial", 20);
                Brush brush402 = Brushes.White;
                Point textPosition402 = new Point(785, 40);
                e.Graphics.DrawString(text402, font402, brush402, textPosition402);
            }
            else {/*无操作，不划线*/}

            if (line35 == true)
            {
                Point startPoint351 = new Point(40, 321);
                Point endPoint351 = new Point(865, 321);
                e.Graphics.DrawLine(pen4, startPoint351, endPoint351);

                Point startPoint352 = new Point(40, 251);
                Point endPoint352 = new Point(865, 251);
                e.Graphics.DrawLine(pen3, startPoint352, endPoint352);

                Point startPoint353 = new Point(40, 396);
                Point endPoint353 = new Point(865, 396);
                e.Graphics.DrawLine(pen3, startPoint353, endPoint353);

                Point startPoint354 = new Point(40, 116);
                Point endPoint354 = new Point(730, 116);
                e.Graphics.DrawLine(pen3, startPoint354, endPoint354);

                Point startPoint355 = new Point(40, 526);
                Point endPoint355 = new Point(865, 526);
                e.Graphics.DrawLine(pen3, startPoint355, endPoint355);

                Point startPoint356 = new Point(460, 150);
                Point endPoint356 = new Point(460, 500);
                e.Graphics.DrawLine(pen4, startPoint356, endPoint356);

                Point startPoint357 = new Point(415, 250);
                Point endPoint357 = new Point(415, 400);
                e.Graphics.DrawLine(pen1, startPoint357, endPoint357);

                Point startPoint358 = new Point(505, 250);
                Point endPoint358 = new Point(505, 400);
                e.Graphics.DrawLine(pen1, startPoint358, endPoint358);

                Point startPoint359 = new Point(330, 250);
                Point endPoint359 = new Point(330, 400);
                e.Graphics.DrawLine(pen1, startPoint359, endPoint359);

                Point startPoint3510 = new Point(65, 250);
                Point endPoint3510 = new Point(65, 400);
                e.Graphics.DrawLine(pen1, startPoint3510, endPoint3510);

                Point startPoint3511 = new Point(155, 250);
                Point endPoint3511 = new Point(155, 400);
                e.Graphics.DrawLine(pen1, startPoint3511, endPoint3511);

                Point startPoint3512 = new Point(240, 250);
                Point endPoint3512 = new Point(240, 400);
                e.Graphics.DrawLine(pen1, startPoint3512, endPoint3512);

                Point startPoint3513 = new Point(590, 250);
                Point endPoint3513 = new Point(590, 400);
                e.Graphics.DrawLine(pen1, startPoint3513, endPoint3513);

                Point startPoint3514 = new Point(680, 250);
                Point endPoint3514 = new Point(680, 400);
                e.Graphics.DrawLine(pen1, startPoint3514, endPoint3514);

                Point startPoint3515 = new Point(765, 250);
                Point endPoint3515 = new Point(765, 400);
                e.Graphics.DrawLine(pen1, startPoint3515, endPoint3515);

                Point startPoint3516 = new Point(855, 250);
                Point endPoint3516 = new Point(855, 400);
                e.Graphics.DrawLine(pen1, startPoint3516, endPoint3516);
            }
            else {/*无操作，不划线*/}

            if (line35mark == true)
            {
                //1X 3.5X 20X 光学倍率下的刻度参考线
                Point startPoint3517 = new Point(765, 115);
                Point endPoint3517 = new Point(865, 115);
                e.Graphics.DrawLine(pen2, startPoint3517, endPoint3517);
                //在刻度参考线上绘制参考刻度
                string text351 = "20 μm";
                Font font351 = new Font("Arial", 20);
                Brush brush351 = Brushes.White;
                Point textPosition351 = new Point(770, 80);
                e.Graphics.DrawString(text351, font351, brush351, textPosition351);
                //倍率显示
                string text352 = "70X";
                Font font352 = new Font("Arial", 20);
                Brush brush352 = Brushes.White;
                Point textPosition352 = new Point(785, 40);
                e.Graphics.DrawString(text352, font352, brush352, textPosition352);
            }
            else {/*无操作，不划线*/}

            if (line30 == true)
            {
                Point startPoint301 = new Point(40, 321);
                Point endPoint301 = new Point(865, 321);
                e.Graphics.DrawLine(pen4, startPoint301, endPoint301);

                Point startPoint302 = new Point(40, 256);
                Point endPoint302 = new Point(865, 256);
                e.Graphics.DrawLine(pen3, startPoint302, endPoint302);

                Point startPoint303 = new Point(40, 391);
                Point endPoint303 = new Point(865, 391);
                e.Graphics.DrawLine(pen3, startPoint303, endPoint303);

                Point startPoint304 = new Point(40, 146);
                Point endPoint304 = new Point(865, 146);
                e.Graphics.DrawLine(pen3, startPoint304, endPoint304);

                Point startPoint305 = new Point(40, 506);
                Point endPoint305 = new Point(865, 506);
                e.Graphics.DrawLine(pen3, startPoint305, endPoint305);

                Point startPoint306 = new Point(460, 150);
                Point endPoint306 = new Point(460, 500);
                e.Graphics.DrawLine(pen4, startPoint306, endPoint306);

                Point startPoint307 = new Point(410, 250);
                Point endPoint307 = new Point(410, 400);
                e.Graphics.DrawLine(pen1, startPoint307, endPoint307);

                Point startPoint308 = new Point(510, 250);
                Point endPoint308 = new Point(510, 400);
                e.Graphics.DrawLine(pen1, startPoint308, endPoint308);

                Point startPoint309 = new Point(357, 250);
                Point endPoint309 = new Point(357, 400);
                e.Graphics.DrawLine(pen1, startPoint309, endPoint309);

                Point startPoint3010 = new Point(104, 250);
                Point endPoint3010 = new Point(104, 400);
                e.Graphics.DrawLine(pen1, startPoint3010, endPoint3010);

                Point startPoint3011 = new Point(204, 250);
                Point endPoint3011 = new Point(204, 400);
                e.Graphics.DrawLine(pen1, startPoint3011, endPoint3011);

                Point startPoint3012 = new Point(257, 250);
                Point endPoint3012 = new Point(257, 400);
                e.Graphics.DrawLine(pen1, startPoint3012, endPoint3012);

                Point startPoint3013 = new Point(563, 250);
                Point endPoint3013 = new Point(563, 400);
                e.Graphics.DrawLine(pen1, startPoint3013, endPoint3013);

                Point startPoint3014 = new Point(663, 250);
                Point endPoint3014 = new Point(663, 400);
                e.Graphics.DrawLine(pen1, startPoint3014, endPoint3014);

                Point startPoint3015 = new Point(716, 250);
                Point endPoint3015 = new Point(716, 400);
                e.Graphics.DrawLine(pen1, startPoint3015, endPoint3015);

                Point startPoint3016 = new Point(816, 250);
                Point endPoint3016 = new Point(816, 400);
                e.Graphics.DrawLine(pen3, startPoint3016, endPoint3016);
            }
            else {/*无操作，不划线*/}

            if (line30mark == true)
            {
                //1X 3.0X 20X 光学倍率下的刻度参考线
                Point startPoint3017 = new Point(770, 115);
                Point endPoint3017 = new Point(860, 115);
                e.Graphics.DrawLine(pen2, startPoint3017, endPoint3017);
                //在刻度参考线上绘制参考刻度
                string text301 = "20 μm";
                Font font301 = new Font("Arial", 20);
                Brush brush301 = Brushes.White;
                Point textPosition301 = new Point(770, 80);
                e.Graphics.DrawString(text301, font301, brush301, textPosition301);
                //倍率显示
                string text302 = "60X";
                Font font302 = new Font("Arial", 20);
                Brush brush302 = Brushes.White;
                Point textPosition302 = new Point(785, 40);
                e.Graphics.DrawString(text302, font302, brush302, textPosition302);
            }
            else {/*无操作，不划线*/}

            if (line25 == true)
            {
                Point startPoint251 = new Point(40, 321);
                Point endPoint251 = new Point(865, 321);
                e.Graphics.DrawLine(pen4, startPoint251, endPoint251);

                Point startPoint252 = new Point(40, 266);
                Point endPoint252 = new Point(865, 266);
                e.Graphics.DrawLine(pen3, startPoint252, endPoint252);

                Point startPoint253 = new Point(40, 381);
                Point endPoint253 = new Point(865, 381);
                e.Graphics.DrawLine(pen3, startPoint253, endPoint253);

                Point startPoint254 = new Point(40, 176);
                Point endPoint254 = new Point(865, 176);
                e.Graphics.DrawLine(pen3, startPoint254, endPoint254);

                Point startPoint255 = new Point(40, 478);
                Point endPoint255 = new Point(865, 478);
                e.Graphics.DrawLine(pen3, startPoint255, endPoint255);

                Point startPoint256 = new Point(460, 150);
                Point endPoint256 = new Point(460, 500);
                e.Graphics.DrawLine(pen4, startPoint256, endPoint256);

                Point startPoint257 = new Point(440, 250);
                Point endPoint257 = new Point(440, 400);
                e.Graphics.DrawLine(pen1, startPoint257, endPoint257);

                Point startPoint258 = new Point(480, 250);
                Point endPoint258 = new Point(480, 400);
                e.Graphics.DrawLine(pen1, startPoint258, endPoint258);

                Point startPoint259 = new Point(353, 250);
                Point endPoint259 = new Point(353, 400);
                e.Graphics.DrawLine(pen1, startPoint259, endPoint259);

                Point startPoint2510 = new Point(186, 250);
                Point endPoint2510 = new Point(186, 400);
                e.Graphics.DrawLine(pen1, startPoint2510, endPoint2510);

                Point startPoint2511 = new Point(226, 250);
                Point endPoint2511 = new Point(226, 400);
                e.Graphics.DrawLine(pen1, startPoint2511, endPoint2511);

                Point startPoint2512 = new Point(313, 250);
                Point endPoint2512 = new Point(313, 400);
                e.Graphics.DrawLine(pen1, startPoint2512, endPoint2512);

                Point startPoint2513 = new Point(567, 250);
                Point endPoint2513 = new Point(567, 400);
                e.Graphics.DrawLine(pen1, startPoint2513, endPoint2513);

                Point startPoint2514 = new Point(607, 250);
                Point endPoint2514 = new Point(607, 400);
                e.Graphics.DrawLine(pen1, startPoint2514, endPoint2514);

                Point startPoint2515 = new Point(694, 250);
                Point endPoint2515 = new Point(694, 400);
                e.Graphics.DrawLine(pen1, startPoint2515, endPoint2515);

                Point startPoint2516 = new Point(734, 250);
                Point endPoint2516 = new Point(734, 400);
                e.Graphics.DrawLine(pen1, startPoint2516, endPoint2516);

                Point startPoint2517 = new Point(821, 250);
                Point endPoint2517 = new Point(821, 400);
                e.Graphics.DrawLine(pen1, startPoint2517, endPoint2517);

                Point startPoint2518 = new Point(99, 250);
                Point endPoint2518 = new Point(99, 400);
                e.Graphics.DrawLine(pen1, startPoint2518, endPoint2518);
            }
            else {/*无操作，不划线*/}

            if (line25mark == true)
            {
                //1X 2.5X 20X 光学倍率下的刻度参考线
                Point startPoint2519 = new Point(780, 115);
                Point endPoint2519 = new Point(850, 115);
                e.Graphics.DrawLine(pen2, startPoint2519, endPoint2519);
                //在刻度参考线上绘制参考刻度
                string text251 = "20 μm";
                Font font251 = new Font("Arial", 20);
                Brush brush251 = Brushes.White;
                Point textPosition251 = new Point(770, 80);
                e.Graphics.DrawString(text251, font251, brush251, textPosition251);
                //倍率显示
                string text252 = "50X";
                Font font252 = new Font("Arial", 20);
                Brush brush252 = Brushes.White;
                Point textPosition252 = new Point(785, 40);
                e.Graphics.DrawString(text252, font252, brush252, textPosition252);
            }
            else {/*无操作，不划线*/}

            if (line20 == true)
            {
                Point startPoint201 = new Point(40, 321);
                Point endPoint201 = new Point(865, 321);
                e.Graphics.DrawLine(pen4, startPoint201, endPoint201);

                Point startPoint202 = new Point(40, 284);
                Point endPoint202 = new Point(865, 284);
                e.Graphics.DrawLine(pen3, startPoint202, endPoint202);

                Point startPoint203 = new Point(40, 358);
                Point endPoint203 = new Point(865, 358);
                e.Graphics.DrawLine(pen3, startPoint203, endPoint203);

                Point startPoint204 = new Point(40, 110);
                Point endPoint204 = new Point(765, 110);
                e.Graphics.DrawLine(pen3, startPoint204, endPoint204);

                Point startPoint205 = new Point(40, 542);
                Point endPoint205 = new Point(865, 542);
                e.Graphics.DrawLine(pen3, startPoint205, endPoint205);

                Point startPoint206 = new Point(460, 150);
                Point endPoint206 = new Point(460, 500);
                e.Graphics.DrawLine(pen4, startPoint206, endPoint206);

                for (int i = 0; i < 7; i++)
                {
                    Point startPoint207 = new Point(110 + 105 * i, 110);
                    Point endPoint207 = new Point(110 + 105 * i, 220);
                    e.Graphics.DrawLine(pen1, startPoint207, endPoint207);
                    Point startPoint208 = new Point(110 + 105 * i, 542);
                    Point endPoint208 = new Point(110 + 105 * i, 432);
                    e.Graphics.DrawLine(pen1, startPoint208, endPoint208);
                    Point startPoint2010 = new Point(180 + 105 * i, 542);
                    Point endPoint2010 = new Point(180 + 105 * i, 432);
                    e.Graphics.DrawLine(pen1, startPoint2010, endPoint2010);
                }
                for (int i = 0; i < 6; i++)//避免挡刻度参考线
                {
                    Point startPoint209 = new Point(180 + 105 * i, 110);
                    Point endPoint209 = new Point(180 + 105 * i, 220);
                    e.Graphics.DrawLine(pen1, startPoint209, endPoint209);
                }
            }
            else {/*无操作，不划线*/}

            if (line20mark == true)
            {
                //1X 2.0X 20X 光学倍率下的刻度参考线
                Point startPoint2011 = new Point(768, 115);
                Point endPoint2011 = new Point(862, 115);
                e.Graphics.DrawLine(pen2, startPoint2011, endPoint2011);
                //在刻度参考线上绘制参考刻度
                string text201 = "30 μm";
                Font font201 = new Font("Arial", 20);
                Brush brush201 = Brushes.White;
                Point textPosition201 = new Point(770, 80);
                e.Graphics.DrawString(text201, font201, brush201, textPosition201);
                //倍率显示
                string text202 = "40X";
                Font font202 = new Font("Arial", 20);
                Brush brush202 = Brushes.White;
                Point textPosition202 = new Point(785, 40);
                e.Graphics.DrawString(text202, font202, brush202, textPosition202);
            }
            else {/*无操作，不划线*/}

            if (line15 == true)
            {
                Point startPoint151 = new Point(40, 321);
                Point endPoint151 = new Point(865, 321);
                e.Graphics.DrawLine(pen4, startPoint151, endPoint151);

                Point startPoint152 = new Point(40, 284);
                Point endPoint152 = new Point(865, 284);
                e.Graphics.DrawLine(pen3, startPoint152, endPoint152);

                Point startPoint153 = new Point(40, 358);
                Point endPoint153 = new Point(865, 358);
                e.Graphics.DrawLine(pen3, startPoint153, endPoint153);

                Point startPoint154 = new Point(40, 220);
                Point endPoint154 = new Point(865, 220);
                e.Graphics.DrawLine(pen3, startPoint154, endPoint154);

                Point startPoint155 = new Point(40, 422);
                Point endPoint155 = new Point(865, 422);
                e.Graphics.DrawLine(pen3, startPoint155, endPoint155);

                Point startPoint156 = new Point(460, 150);
                Point endPoint156 = new Point(460, 500);
                e.Graphics.DrawLine(pen4, startPoint156, endPoint156);
                for (int i = 0; i < 5; i++)
                {
                    Point startPoint157 = new Point(125 + 78 * i, 50);
                    Point endPoint157 = new Point(125 + 78 * i, 120);
                    e.Graphics.DrawLine(pen1, startPoint157, endPoint157);
                    Point startPoint158 = new Point(125 + 78 * i, 280);
                    Point endPoint158 = new Point(125 + 78 * i, 350);
                    e.Graphics.DrawLine(pen1, startPoint158, endPoint158);
                    Point startPoint159 = new Point(125 + 78 * i, 520);
                    Point endPoint159 = new Point(125 + 78 * i, 590);
                    e.Graphics.DrawLine(pen1, startPoint159, endPoint159);
                }
                for (int i = 0; i < 4; i++)
                {
                    Point startPoint1510 = new Point(175 + 78 * i, 50);
                    Point endPoint1510 = new Point(175 + 78 * i, 120);
                    e.Graphics.DrawLine(pen1, startPoint1510, endPoint1510);
                    Point startPoint1511 = new Point(175 + 78 * i, 280);
                    Point endPoint1511 = new Point(175 + 78 * i, 350);
                    e.Graphics.DrawLine(pen1, startPoint1511, endPoint1511);
                    Point startPoint1512 = new Point(175 + 78 * i, 520);
                    Point endPoint1512 = new Point(175 + 78 * i, 590);
                    e.Graphics.DrawLine(pen1, startPoint1512, endPoint1512);
                }
                for (int i = 0; i < 5; i++)
                {
                    Point startPoint1514 = new Point(795 - 78 * i, 280);
                    Point endPoint1514 = new Point(795 - 78 * i, 350);
                    e.Graphics.DrawLine(pen1, startPoint1514, endPoint1514);
                    Point startPoint1515 = new Point(795 - 78 * i, 520);
                    Point endPoint1515 = new Point(795 - 78 * i, 590);
                    e.Graphics.DrawLine(pen1, startPoint1515, endPoint1515);
                }
                for (int i = 0; i < 4; i++)
                {
                    Point startPoint1513 = new Point(717 - 78 * i, 50);
                    Point endPoint1513 = new Point(717 - 78 * i, 120);
                    e.Graphics.DrawLine(pen1, startPoint1513, endPoint1513);//避免刻度参考线
                    Point startPoint1516 = new Point(745 - 78 * i, 50);
                    Point endPoint1516 = new Point(745 - 78 * i, 120);
                    e.Graphics.DrawLine(pen1, startPoint1516, endPoint1516);
                    Point startPoint1517 = new Point(745 - 78 * i, 280);
                    Point endPoint1517 = new Point(745 - 78 * i, 350);
                    e.Graphics.DrawLine(pen1, startPoint1517, endPoint1517);
                    Point startPoint1518 = new Point(745 - 78 * i, 520);
                    Point endPoint1518 = new Point(745 - 78 * i, 590);
                    e.Graphics.DrawLine(pen1, startPoint1518, endPoint1518);
                }
            }
            else {/*无操作，不划线*/}

            if (line15mark == true)
            {
                //1X 1.5X 20X 光学倍率下的刻度参考线
                Point startPoint1519 = new Point(767, 115);
                Point endPoint1519 = new Point(863, 115);
                e.Graphics.DrawLine(pen2, startPoint1519, endPoint1519);
                //在刻度参考线上绘制参考刻度
                string text151 = "50 μm";
                Font font151 = new Font("Arial", 20);
                Brush brush151 = Brushes.White;
                Point textPosition151 = new Point(770, 80);
                e.Graphics.DrawString(text151, font151, brush151, textPosition151);
                //倍率显示
                string text152 = "30X";
                Font font152 = new Font("Arial", 20);
                Brush brush152 = Brushes.White;
                Point textPosition152 = new Point(785, 40);
                e.Graphics.DrawString(text152, font152, brush152, textPosition152);
            }
            else {/*无操作，不划线*/}

            if (line10 == true)
            {
                Point startPoint101 = new Point(40, 321);
                Point endPoint101 = new Point(865, 321);
                e.Graphics.DrawLine(pen4, startPoint101, endPoint101);

                Point startPoint102 = new Point(40, 299);
                Point endPoint102 = new Point(865, 299);
                e.Graphics.DrawLine(pen3, startPoint102, endPoint102);

                Point startPoint103 = new Point(40, 343);
                Point endPoint103 = new Point(865, 343);
                e.Graphics.DrawLine(pen3, startPoint103, endPoint103);

                Point startPoint104 = new Point(40, 220);
                Point endPoint104 = new Point(865, 220);
                e.Graphics.DrawLine(pen3, startPoint104, endPoint104);

                Point startPoint105 = new Point(40, 422);
                Point endPoint105 = new Point(865, 422);
                e.Graphics.DrawLine(pen3, startPoint105, endPoint105);

                Point startPoint106 = new Point(460, 150);
                Point endPoint106 = new Point(460, 500);
                e.Graphics.DrawLine(pen4, startPoint106, endPoint106);
                for (int i = 0; i < 7; i++)
                {
                    Point startPoint107 = new Point(140 + 50 * i, 70);
                    Point endPoint107 = new Point(140 + 50 * i, 120);
                    e.Graphics.DrawLine(pen1, startPoint107, endPoint107);
                    Point startPoint108 = new Point(140 + 50 * i, 225);
                    Point endPoint108 = new Point(140 + 50 * i, 275);
                    e.Graphics.DrawLine(pen1, startPoint108, endPoint108);
                    Point startPoint109 = new Point(140 + 50 * i, 375);
                    Point endPoint109 = new Point(140 + 50 * i, 425);
                    e.Graphics.DrawLine(pen1, startPoint109, endPoint109);
                    Point startPoint1010 = new Point(140 + 50 * i, 530);
                    Point endPoint1010 = new Point(140 + 50 * i, 580);
                    e.Graphics.DrawLine(pen1, startPoint1010, endPoint1010);
                }
                for (int i = 0; i < 6; i++)
                {
                    Point startPoint1011 = new Point(175 + 50 * i, 70);
                    Point endPoint1011 = new Point(175 + 50 * i, 120);
                    e.Graphics.DrawLine(pen1, startPoint1011, endPoint1011);
                    Point startPoint1012 = new Point(175 + 50 * i, 225);
                    Point endPoint1012 = new Point(175 + 50 * i, 275);
                    e.Graphics.DrawLine(pen1, startPoint1012, endPoint1012);
                    Point startPoint1013 = new Point(175 + 50 * i, 375);
                    Point endPoint1013 = new Point(175 + 50 * i, 425);
                    e.Graphics.DrawLine(pen1, startPoint1013, endPoint1013);
                    Point startPoint1014 = new Point(175 + 50 * i, 530);
                    Point endPoint1014 = new Point(175 + 50 * i, 580);
                    e.Graphics.DrawLine(pen1, startPoint1014, endPoint1014);
                }
                for (int i = 0; i < 7; i++)
                {
                    Point startPoint1016 = new Point(780 - 50 * i, 225);
                    Point endPoint1016 = new Point(780 - 50 * i, 275);
                    e.Graphics.DrawLine(pen1, startPoint1016, endPoint1016);
                    Point startPoint1017 = new Point(780 - 50 * i, 375);
                    Point endPoint1017 = new Point(780 - 50 * i, 425);
                    e.Graphics.DrawLine(pen1, startPoint1017, endPoint1017);
                    Point startPoint1018 = new Point(780 - 50 * i, 530);
                    Point endPoint1018 = new Point(780 - 50 * i, 580);
                    e.Graphics.DrawLine(pen1, startPoint1018, endPoint1018);
                }
                for (int i = 0; i < 6; i++)
                {
                    Point startPoint1015 = new Point(730 - 50 * i, 70);
                    Point endPoint1015 = new Point(730 - 50 * i, 120);
                    e.Graphics.DrawLine(pen1, startPoint1015, endPoint1015);//避免档刻度参考
                    Point startPoint1019 = new Point(745 - 50 * i, 70);
                    Point endPoint1019 = new Point(745 - 50 * i, 120);
                    e.Graphics.DrawLine(pen1, startPoint1019, endPoint1019);
                    Point startPoint1020 = new Point(745 - 50 * i, 225);
                    Point endPoint1020 = new Point(745 - 50 * i, 275);
                    e.Graphics.DrawLine(pen1, startPoint1020, endPoint1020);
                    Point startPoint1021 = new Point(745 - 50 * i, 375);
                    Point endPoint1021 = new Point(745 - 50 * i, 425);
                    e.Graphics.DrawLine(pen1, startPoint1021, endPoint1021);
                    Point startPoint1022 = new Point(745 - 50 * i, 530);
                    Point endPoint1022 = new Point(745 - 50 * i, 580);
                    e.Graphics.DrawLine(pen1, startPoint1022, endPoint1022);
                }
            }
            else {/*无操作，不划线*/}

            if (line10mark == true)
            {
                //1X 1.0X 20X 光学倍率下的刻度参考线
                Point startPoint1023 = new Point(780, 115);
                Point endPoint1023 = new Point(850, 115);
                e.Graphics.DrawLine(pen2, startPoint1023, endPoint1023);
                //在刻度参考线上绘制参考刻度
                string text101 = "50 μm";
                Font font101 = new Font("Arial", 20);
                Brush brush101 = Brushes.White;
                Point textPosition101 = new Point(770, 80);
                e.Graphics.DrawString(text101, font101, brush101, textPosition101);
                //倍率显示
                string text102 = "20X";
                Font font102 = new Font("Arial", 20);
                Brush brush102 = Brushes.White;
                Point textPosition102 = new Point(785, 40);
                e.Graphics.DrawString(text102, font102, brush102, textPosition102);
            }
            else {/*无操作，不划线*/}

            if (line07 == true)
            {
                Point startPoint071 = new Point(40, 321);
                Point endPoint071 = new Point(865, 321);
                e.Graphics.DrawLine(pen4, startPoint071, endPoint071);

                Point startPoint072 = new Point(40, 302);
                Point endPoint072 = new Point(865, 302);
                e.Graphics.DrawLine(pen3, startPoint072, endPoint072);

                Point startPoint073 = new Point(40, 340);
                Point endPoint073 = new Point(865, 340);
                e.Graphics.DrawLine(pen3, startPoint073, endPoint073);

                Point startPoint074 = new Point(40, 228);
                Point endPoint074 = new Point(865, 228);
                e.Graphics.DrawLine(pen3, startPoint074, endPoint074);

                Point startPoint075 = new Point(40, 414);
                Point endPoint075 = new Point(865, 414);
                e.Graphics.DrawLine(pen3, startPoint075, endPoint075);

                Point startPoint076 = new Point(460, 150);
                Point endPoint076 = new Point(460, 500);
                e.Graphics.DrawLine(pen4, startPoint076, endPoint076);

                Point startPoint077 = new Point(200, 90);
                Point endPoint077 = new Point(720, 90);
                e.Graphics.DrawLine(pen1, startPoint077, endPoint077);
                Point startPoint078 = new Point(200, 90);
                Point endPoint078 = new Point(200, 552);
                e.Graphics.DrawLine(pen1, startPoint078, endPoint078);
                Point startPoint079 = new Point(720, 90);
                Point endPoint079 = new Point(720, 552);
                e.Graphics.DrawLine(pen1, startPoint079, endPoint079);
                Point startPoint0710 = new Point(200, 552);
                Point endPoint0710 = new Point(720, 552);
                e.Graphics.DrawLine(pen1, startPoint0710, endPoint0710);
            }
            else {/*无操作，不划线*/}

            if (line07mark == true)
            {
                //1X 0.7X 20X 光学倍率下的刻度参考线
                Point startPoint0711 = new Point(790, 115);
                Point endPoint0711 = new Point(840, 115);
                e.Graphics.DrawLine(pen2, startPoint0711, endPoint0711);
                //在刻度参考线上绘制参考刻度
                string text071 = "50 μm";
                Font font071 = new Font("Arial", 20);
                Brush brush071 = Brushes.White;
                Point textPosition071 = new Point(770, 80);
                e.Graphics.DrawString(text071, font071, brush071, textPosition071);
                //倍率显示
                string text072 = "14X";
                Font font072 = new Font("Arial", 20);
                Brush brush072 = Brushes.White;
                Point textPosition072 = new Point(785, 40);
                e.Graphics.DrawString(text072, font072, brush072, textPosition072);
            }
            else {/*无操作，不划线*/}
        }



    }
}
